package com.example.testspringwebflux.bean;

import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.StandardEnvironment;

import java.util.Properties;

/**
 * BinderTest
 *
 * @author xule
 * @since 2024/06/21
 */
public class BinderTest {

    public static void main(String[] args) {
        StandardEnvironment environment = new StandardEnvironment();
        Properties properties = new Properties();
        properties.put("demo.name", "测试");
        PropertiesPropertySource mapPropertySource = new PropertiesPropertySource("test", properties);
        environment.getPropertySources().addLast(mapPropertySource);
        Test a = Binder.get(environment).bind("demo", Test.class).get();
        System.out.println(a);

        MapConfigurationPropertySource map = new MapConfigurationPropertySource();
        map.put("demo.name", "测试");
        Binder binder = new Binder(map);
        Test demo = binder.bind("demo", Test.class).get();
        System.out.println(demo);
    }
}
